package com.example.helloworld;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.graphics.DashPathEffect;
import android.graphics.NinePatch;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.widget.Button;
import android.widget.TableRow;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    public static int screenWidth;
    private static int screenHeight;
    private Button squat;   // 深蹲按钮
    private void getScreenSize(){
        Display defaultDisplay = getWindowManager().getDefaultDisplay();
        Point point = new Point();
        defaultDisplay.getSize(point);
        screenWidth = point.x;
        screenHeight = point.y;
    }

    private void setMenuLayoutSize(){
        TableRow tr10 = findViewById(R.id.TL10);
        TableRow.LayoutParams lp_tr10 = (TableRow.LayoutParams) tr10.getLayoutParams();
        lp_tr10.width = (screenWidth  / 3);
        lp_tr10.height = (screenHeight / Utils.MENUS_COL);

        TableRow tr11 = findViewById(R.id.TL11);
        TableRow.LayoutParams lp_tr11 = (TableRow.LayoutParams) tr11.getLayoutParams();
        lp_tr11.width = (screenWidth / 3);
        lp_tr11.height = (screenHeight / Utils.MENUS_COL);

        TableRow tr20 = findViewById(R.id.TL20);
        TableRow.LayoutParams lp_tr20 = (TableRow.LayoutParams) tr20.getLayoutParams();
        lp_tr20.width = ((screenWidth - 30) / 2);
        lp_tr20.height = (screenHeight / Utils.MENUS_COL);

        TableRow tr21 = findViewById(R.id.TL21);
        TableRow.LayoutParams lp_tr21 = (TableRow.LayoutParams) tr21.getLayoutParams();
        lp_tr21.width = ((screenWidth - 30) / 2);
        lp_tr21.height = (screenHeight / Utils.MENUS_COL);

        TableRow tr30 = findViewById(R.id.TL30);
        TableRow.LayoutParams lp_tr30 = (TableRow.LayoutParams) tr30.getLayoutParams();
        lp_tr30.width = ((screenWidth - 30) / 2);
        lp_tr30.height = (screenHeight / Utils.MENUS_COL);

        TableRow tr31 = findViewById(R.id.TL31);
        TableRow.LayoutParams lp_tr31 = (TableRow.LayoutParams) tr31.getLayoutParams();
        lp_tr31.width = ((screenWidth - 30) / 2);
        lp_tr31.height = (screenHeight / Utils.MENUS_COL);

        TableRow tr40 = findViewById(R.id.TL40);
        TableRow.LayoutParams lp_tr40 = (TableRow.LayoutParams) tr40.getLayoutParams();
        lp_tr40.width = ((screenWidth - 30) / 2);
        lp_tr40.height = (screenHeight / Utils.MENUS_COL);

        TableRow tr41 = findViewById(R.id.TL41);
        TableRow.LayoutParams lp_tr41 = (TableRow.LayoutParams) tr41.getLayoutParams();
        lp_tr41.width = ((screenWidth - 30) / 2);
        lp_tr41.height = (screenHeight / Utils.MENUS_COL);

        TableRow tr50 = findViewById(R.id.TL50);
        TableRow.LayoutParams lp_tr50 = (TableRow.LayoutParams) tr50.getLayoutParams();
        lp_tr50.width = ((screenWidth - 30) / 2);
        lp_tr50.height = (screenHeight / Utils.MENUS_COL);

        TableRow tr51 = findViewById(R.id.TL51);
        TableRow.LayoutParams lp_tr51 = (TableRow.LayoutParams) tr51.getLayoutParams();
        lp_tr51.width = ((screenWidth - 30) / 2);
        lp_tr51.height = (screenHeight / Utils.MENUS_COL);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getScreenSize();
        setMenuLayoutSize();

        //  获取按钮id
        squat = findViewById(R.id.squat_button);
        // 注册监听事件
        squat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SquatInterface.class);
                startActivity(intent);
            }
        });

        //  获取按钮id
        squat = findViewById(R.id.plank_button);
        // 注册监听事件
        squat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SquatInterface.class);
                startActivity(intent);
            }
        });
        // TODO 改名并且编写XML文件
        //  获取按钮id
        squat = findViewById(R.id.squat_button);
        // 注册监听事件
        squat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SquatInterface.class);
                startActivity(intent);
            }
        });

        //  获取按钮id
        squat = findViewById(R.id.squat_button);
        // 注册监听事件
        squat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SquatInterface.class);
                startActivity(intent);
            }
        });

        //  获取按钮id
        squat = findViewById(R.id.squat_button);
        // 注册监听事件
        squat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SquatInterface.class);
                startActivity(intent);
            }
        });

        //  获取按钮id
        squat = findViewById(R.id.squat_button);
        // 注册监听事件
        squat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SquatInterface.class);
                startActivity(intent);
            }
        });

        //  获取按钮id
        squat = findViewById(R.id.squat_button);
        // 注册监听事件
        squat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SquatInterface.class);
                startActivity(intent);
            }
        });

        //  获取按钮id
        squat = findViewById(R.id.squat_button);
        // 注册监听事件
        squat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SquatInterface.class);
                startActivity(intent);
            }
        });

        //  获取按钮id
        squat = findViewById(R.id.squat_button);
        // 注册监听事件
        squat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SquatInterface.class);
                startActivity(intent);
            }
        });

        //  获取按钮id
        squat = findViewById(R.id.squat_button);
        // 注册监听事件
        squat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SquatInterface.class);
                startActivity(intent);
            }
        });

        //  获取按钮id
        squat = findViewById(R.id.squat_button);
        // 注册监听事件
        squat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SquatInterface.class);
                startActivity(intent);
            }
        });
    }
}